import { Public } from '@/decorators/visit.decorator';
import {
  Controller,
  Post,
  Query,
  UploadedFile,
  UseInterceptors,
} from '@nestjs/common';
import { FileInterceptor } from '@nestjs/platform-express';

import { ApiOperation, ApiTags } from '@nestjs/swagger';
import { UploadService } from './upload.service';
@ApiTags('文件管理')
@Controller('upload')
export class UploadController {
  constructor(private readonly uploadService: UploadService) {}

  @Public()
  @ApiOperation({ summary: '文件上传' })
  @Post('/uploadFile')
  @UseInterceptors(FileInterceptor('file'))
  async upload(
    @UploadedFile() file: Express.Multer.File,
    @Query('width') width: number,
    @Query('height') height: number,
  ) {
    console.log(width, height);
    return this.uploadService.uploadFile(file, width, height);
  }
}
